/**
* 左边菜单
*/ 
<template>
  <el-menu default-active="2" :collapse="collapsed" collapse-transition router :default-active="$route.path" unique-opened class="el-menu-vertical-demo" background-color="#334157" text-color="#fff" active-text-color="#ffd04b">
    <div class="logobox">
      <img class="logoimg" src="../assets/img/logo.png" alt="">
    </div>
    <el-submenu v-for="menu in allmenu" :key="menu.menuid" :index="menu.menuname">
      <template slot="title">
        <i class="iconfont" :class="menu.icon"></i>
        <span>{{menu.menuname}}</span>
      </template>
      <el-menu-item-group>
        <el-menu-item v-for="chmenu in menu.menus" :index="'/'+chmenu.url" :key="chmenu.menuid">
          <i class="iconfont" :class="chmenu.icon"></i>
          <span>{{chmenu.menuname}}</span>
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>
<script>
import { menu } from '../api/userMG'
export default {
  name: 'leftnav',
  data() {
    return {
      collapsed: false,
      allmenu: []
    }
  },
  // 创建完毕状态(里面是操作)
  created() {
    // 获取图形验证码
    let res = {
      success: true,
      data: [
        {
          menuid: 1,
          icon: 'li-icon-xiangmuguanli',
          menuname: '会议',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 2,
              icon: 'icon-order-manage',
              menuname: '会议主页',
              hasThird: 'N',
              url: 'meeting/homepage',
              menus: null
            },
            {
              menuid: 3,
              icon: 'icon-order-manage',
              menuname: '文件数据',
              hasThird: 'N',
              url: 'meeting/data',
              menus: null
            },
            {
              menuid: 3,
              icon: 'icon-order-manage',
              menuname: '电子白板',
              hasThird: 'N',
              url: 'meeting/whiteboard',
              menus: null
            },
          ]
        },
        {
          menuid: 33,
          icon: 'li-icon-dingdanguanli',
          menuname: '会议管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 34,
              icon: 'icon-order-manage',
              menuname: '全部会议',
              hasThird: 'N',
              url: 'conference/allmeeting',
              menus: null
            },
            {
              menuid: 35,
              icon: 'icon-order-manage',
              menuname: '创建会议',
              hasThird: 'N',
              url: 'conference/cmeeting',
              menus: null
            }
          ]
        },
        {
          menuid: 73,
          icon: 'li-icon-shangchengxitongtubiaozitihuayuanwenjian91',
          menuname: '工具管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 74,
              icon: 'icon-provider-manage',
              menuname: '德尔菲',
              hasThird: 'N',
              url: 'machine/MachineConfig',
              menus: null
            },
            {
              menuid: 75,
              icon: 'icon-provider-manage',
              menuname: 'SWOT',
              hasThird: 'N',
              menus: null
            },
            {
              menuid: 76,
              icon: 'icon-provider-manage',
              menuname: '竞争性假设',
              hasThird: 'N',
              menus: null
            },
            {
              menuid: 77,
              icon: 'icon-provider-manage',
              menuname: '工具使用情况',
              hasThird: 'N',
              url: 'pay/Config',
              menus: null
            }
          ]
        },
        {
          menuid: 127,
          icon: 'li-icon-shangchengxitongtubiaozitihuayuanwenjian91',
          menuname: '数据管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 128,
              icon: 'icon-provider-manage',
              menuname: '报文数据',
              hasThird: 'N',
              url: 'file/message',
              menus: null
            },
            {
              menuid: 129,
              icon: 'icon-provider-manage',
              menuname: '多媒体数据',
              hasThird: 'N',
              url: 'file/multimedia',
              menus: null
            },
            {
              menuid: 130,
              icon: 'icon-provider-manage',
              menuname: '外部专家数据',
              hasThird: 'N',
              url: 'file/professor',
              menus: null
            },
            {
              menuid: 131,
              icon: 'icon-provider-manage',
              menuname: '语音白板数据',
              hasThird: 'N',
              url: 'file/voice',
              menus: null
            },
            {
              menuid: 132,
              icon: 'icon-provider-manage',
              menuname: '历史会议数据',
              hasThird: 'N',
              url: 'file/history',
              menus: null
            },
            {
              menuid: 133,
              icon: 'icon-provider-manage',
              menuname: '其他数据',
              hasThird: 'N',
              url: 'file/other',
              menus: null
            },
          ]
        },
        {
          menuid: 150,
          icon: 'li-icon-xitongguanli',
          menuname: '系统管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid:151,
              icon: 'icon-cus-manage',
              menuname: '用户管理',
              hasThird: 'N',
              url: 'system/user',
              menus: null
            },
            {
              menuid: 152,
              icon: 'icon-news-manage',
              menuname: '角色管理',
              hasThird: 'N',
              url: 'system/Role',
              menus: null
            },
            {
              menuid: 154,
              icon: 'icon-cs-manage',
              menuname: '领域管理',
              hasThird: 'N',
              url: 'system/Dept',
              menus: null
            },
            {
              menuid: 155,
              icon: 'icon-cms-manage',
              menuname: '地址管理',
              hasThird: 'N',
              url: 'system/Permission',
              menus: null
            }
          ]
        },
        {
          menuid: 170,
          icon: 'li-icon-xitongguanli',
          menuname: '日志管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid:171,
              icon: 'icon-cus-manage',
              menuname: '登录日志',
              hasThird: 'N',
              url: 'log/Log',
              menus: null
            },
            {
              menuid: 172,
              icon: 'icon-news-manage',
              menuname: '操作日志',
              hasThird: 'N',
              url: 'log/operation',
              menus: null
            },
            {
              menuid: 173,
              icon: 'icon-cs-manage',
              menuname: '系统日志',
              hasThird: 'N',
              url: 'log/systemlog',
              menus: null
            },
          ]
        },
      ],
      msg: 'success'
    }
          this.allmenu = res.data
    
    // menu(localStorage.getItem('logintoken'))
    //   .then(res => {
    //     console.log(JSON.stringify(res))
    //     if (res.success) {
    //       this.allmenu = res.data
    //     } else {
    //       this.$message.error(res.msg)
    //       return false
    //     }
    //   })
    //   .catch(err => {
    //     this.$message.error('菜单加载失败，请稍后再试！')
    //   })
    // 监听
    this.$root.Bus.$on('toggle', value => {
      this.collapsed = !value
    })
  }
}
</script>
<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 240px;
  min-height: 400px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
  text-align: left;
}
.el-menu-item-group__title {
  padding: 0px;
}
.el-menu-bg {
  background-color: #1f2d3d !important;
}
.el-menu {
  border: none;
}
.logobox {
  height: 40px;
  line-height: 40px;
  color: #9d9d9d;
  font-size: 20px;
  text-align: center;
  padding: 20px 0px;
}
.logoimg {
  height: 40px;
}
</style>